let vm = new Vue({
    el: "#userMain",
    data: {
        pageInfo: {
            pageNum: 1,
            pageSize: 3,
        },
        params:{
            value:'',
        },
        userLoginInfo: {},
        flag: "",
        detail: {},
        followList: []
    },
    methods: {
        logout: function () {
            axios({
                url: `user/logout`,
            }).then(res => {
                sessionStorage.clear();
                location.href = "logout";
            })
        },
        herDetail: function (pageList) {
            layer.pageList = pageList;//role数据，绑定到layer上，传递给子窗口
            let index = layer.open({
                type: 2,
                title: false,
                content: ['getDetail'],
                area: ['55%', '75%'],
                end: () => {//将then函数中的this传递到end的回调函数中
                    //刷新页面数据
                    this.selectAll(1, this.pageInfo.pageSize);
                }
            });
        },
        isFollowHer: function (id) {
            axios({
                url: `userList/isFollowHer/${id}`,
                method: 'post',
            }).then(res => {
                this.followList = res.data.data
            })
        },
        forfollowList(uid) {
            for (let i = 0; i < this.followList.length; i++) {
                if (this.followList[i] == uid) {
                    return true;
                }
            }
            return false;
        },
        addFollow: function (uid) {
            axios({
                url: `userList/follow/${uid}`,
                method: 'get'
            }).then(res => {
                alert(res.data.message);
            })
        },
        /**
         * 条件分页
         * @param pageNum
         * @param pageSize
         */
        findNameLimit: function (pageNum,pageSize) {
            axios({
                url: `userList/pageCondition/${pageNum}/${pageSize}`,
                method: 'post',
                data:this.params
            }).then(res => {
                this.pageInfo=res.data.data
            })
        }
    },
    created: function () {
        let userInfo = sessionStorage.getItem("vmUserInfo");
        if (userInfo != null) {
            this.userLoginInfo = JSON.parse(userInfo);
        } else {
            location.href = "";
        }

        // 页面初始化就 查找列表信息
        this.findNameLimit(this.pageInfo.pageNum, this.pageInfo.pageSize);
        this.flag = 1;

        this.isFollowHer(this.userLoginInfo.data.id)
    },


});